//
//  MessageFunctionBtn.m
//  MessageChat
//
//  Created by Mr.H on 2018/1/23.
//  Copyright © 2018年 Mr.H. All rights reserved.
//

#import "MessageFunctionBtn.h"
#import "Masonry.h"
@interface MessageFunctionBtn()

/**图片*/
@property (nonatomic, strong) UIImageView *imageViewTop;

/**文字*/
@property (nonatomic, strong) UILabel *titleLabelBottom;

/**底部框*/
@property (nonatomic, strong) UIView *bottomView;

@end

@implementation MessageFunctionBtn

- (instancetype)init
{
    self = [super init];
    
    if (self) {
        
        [self creatUI];
        
    }
    
    return self;
    
}

- (void)creatUI {
    
    [self.bottomView addSubview:self.imageViewTop];
    
    [self addSubview:self.bottomView];
    
    [self addSubview:self.titleLabelBottom];
    
    [self layout];
    
}

- (void)layout {
    
    [self.imageViewTop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.mas_equalTo(0);
        make.size.mas_equalTo(CGSizeMake(28, 20));
    }];
    
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_equalTo(0);
        make.height.mas_equalTo(55);
    }];
    
    [self.titleLabelBottom mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bottomView.mas_bottom).mas_offset(10);
        make.right.left.mas_equalTo(0);
    }];
    
}

- (void)setImageName:(NSString *)imageName titleName:(NSString *)titleName {
    
    self.imageViewTop.image = [UIImage imageNamed:imageName];
    
    self.titleLabelBottom.text = titleName;
    
}

- (UIImageView *)imageViewTop {
    
    if (!_imageViewTop) {
        
        _imageViewTop = [[UIImageView alloc] init];
        
    }
    
    return _imageViewTop;
    
}

- (UILabel *)titleLabelBottom {
    
    if (!_titleLabelBottom) {
        
        _titleLabelBottom = [[UILabel alloc] init];
        
        _titleLabelBottom.textAlignment = NSTextAlignmentCenter;
        
        _titleLabelBottom.font = [UIFont systemFontOfSize:14];
        
        _titleLabelBottom.textColor = [UIColor redColor];
        
    }
    
    return _titleLabelBottom;
    
}

- (UIView *)bottomView {
    
    if (!_bottomView) {
        
        _bottomView = [[UIView alloc]init];
        
        _bottomView.layer.cornerRadius = 10;
        
        _bottomView.layer.masksToBounds = YES;
        
        _bottomView.layer.borderColor = [UIColor redColor].CGColor;
        
        _bottomView.layer.borderWidth = 0.5;
        
    }
    
    return _bottomView;
    
}

@end
